import json

from werkzeug.routing import BaseConverter
from flask import Flask, request, url_for, redirect, jsonify
from flask import Response

app = Flask(__name__)

app.config.from_pyfile('config.py')


# 自定义 响应
@app.route('/get/<int:id>')
def get_id(id):
    # return f'Hello id  {id}'
    data = {
            'id':id,
            'test':'info'
            }
    return Response(json.dumps(data), status=200,headers={'test':'test'})


# 通过redirect进行重定向
@app.route('/users/<int:user_id>')
def user_info(user_id):
  return redirect(url_for('get_id', id=12))


if __name__ == '__main__':
    app.run()
